import re

pattern = r"\d+"  # 匹配数字
text = "123abc456def789"

result = re.sub(pattern, "X", text)
print(result)  # 输出：XabcXdefX
